<template>
	<view class="orderGoods borRadius14">
		<view class='total' @click="jumpToOrderOperationInformationPage">
				<span>
					共{{ orderProNum?orderProNum:totalNmu}}件商品
				</span>
				<uni-icons type="forward" size="15"></uni-icons>
			</view>
		<view class='goodWrapper pad30'>
			<view class='item acea-row row-between-wrapper' v-for="(item,index) in cartInfo" :key="index"
				>
				<view class='pictrue' @click="jumpCon(item.productId)">
					<image :src='item.image'></image>
				</view>
				<view class='text'>
					<view class='acea-row row-between-wrapper' @click="jumpCon(item.productId)">
						<view class='name line1' style="width: 400rpx;">{{item.productName ? item.productName : item.storeName}}</view>
						<view class='num'>x {{item.payNum ? item.payNum : item.cartNum}}</view>
						
					</view>
					<view class='attr line1' v-if="item.sku" @click="jumpCon(item.productId)">{{item.sku}}</view>
					<view class="cart acea-row row-between-wrapper" style="margin-left: 1rpx;z-index:500;" v-if="!paid&&panduan">
						<view class="carnum acea-row row-left" >
							<view class="item reduce" 
								>
								<button type="primary" @click="CartNumjian(index,item.cartNum,item.productId)" style="margin-right: 20rpx;margin-top:5rpx;">-</button>
							</view>
							<view class='item num'>
								<input type="number" v-model="item.cartNum"
									data-name="productSelect.cart_num"
									></input>
							</view>
							<view  class="item plus" >
								<button type="primary"  @click="CartNumjia(index,item.cartNum,item.productId)" style="margin-left: 20rpx;margin-top:5rpx;">+</button>
							</view>
							
						</view>
					</view>
					<view class='money font-color' @click="jumpCon(item.productId)">￥{{item.price}}</view>
					<view class='evaluate' v-if='item.isReply==0 && evaluate==2' @click.stop="evaluateTap(item)">评价
					</view>
					<view class='evaluate' v-else-if="item.isReply==1">已评价</view>
				</view>
			</view>
		</view>
	</view>

</template>

<script>
	import {
		qrderQuantity
	} from '@/api/api.js';
	export default {
		props: {
			panduan:{},
			paid:{
				
			},
			evaluate: {
				type: Number,
				default: 0,
			},
			cartInfo: {
				type: Array,
				default: function() {
					return [];
				}
			},
			orderId: {
				type: String,
				default: '',
			},
			ids: {
				type: Number,
				default: 0,
			},
			jump: {
				type: Boolean,
				default: false,
			},
			orderProNum: {
				type: Number,
				default: function() {
					return 0;
				}
			},
			productType: {
				type: Number,
				default: function() {
					return 0;
				}
			}
		},
		data() {
			return {
				totalNmu: '',
				productSelect:1
			};
		},
		watch: {
			cartInfo: function(nVal, oVal) {
				let num = 0
				nVal.forEach((item, index) => {
					num += item.cartNum
				})
				this.totalNmu = num
				// this.productSelect=this.cartInfo.cartNum
			}
		},
		methods: {
			/**
			 * 跳转到订单操作信息页面
			 * */
			jumpToOrderOperationInformationPage(){
				console.log('页面跳转');
				uni.navigateTo({
					url: '/pages/users/order_operation_information/order_operation_information'
				});
			},
			CartNumjia(index,cartNum,attrId){
				let that=this
				let props=[
					{
					"orderNum":++cartNum,
					"productId":attrId,
					}]
					qrderQuantity({orderNo:that.orderId,storeNumRequests:props}).then(res=>{
						that.$emit("gengx")
					})
			},
			CartNumjian(index,cartNum,attrId){
				let that=this
					if(cartNum>1){
						let props=[
								{
								"orderNum":--cartNum,
								"productId":attrId,
								}]
						qrderQuantity({orderNo:that.orderId,storeNumRequests:props}).then(res=>{
								that.$emit("gengx")
							})
					}
					
			},
			evaluateTap(item) {
				uni.navigateTo({
					url: "/pages/users/goods_comment_con/index?unique=" + item.attrId + "&orderId=" + this.orderId + '&id=' + this.ids
				})
			},
			jumpCon: function(id) {
				let type = this.productType==0?'normal':'video'
				if (this.jump) {
					uni.navigateTo({
						url: `/pages/goods_details/index?id=${id}&type=${type}`
					})
				}
			}
		}
	}
</script>

<style scoped lang="scss">
	.orderGoods {
		background-color: #fff;
		margin-top: 15rpx;
	}

	.orderGoods .total {
		// width: 100%;
		// height: 86rpx;
		padding: 0 24rpx;
		border-bottom: 2rpx solid #f0f0f0;
		font-size: 30rpx;
		color: #282828;
		line-height: 86rpx;
		// box-sizing: border-box;
		display: flex;
		justify-content: space-between;
	}

	.pictrue image {
		background: #f4f4f4;
	}
	.cart .title {
			font-size: 35rpx;
			position: absolute;
			margin-top: 10rpx;
			left:50rpx;
			color: #999;
		}
		.cart .carnum {
			height: 54rpx;
			// margin-top: 20rpx;
		}
		
		 .cart .carnum view {
			// border: 1px solid #a4a4a4;
			width: 84rpx;
			text-align: center;
			height: 100%;
			line-height: 54rpx;
			color: #282828;
			font-size: 45rpx;
		}
		
		 .cart .carnum .reduce {
			border-right: 0;
			border-radius: 6rpx 0 0 6rpx;
			line-height: 48rpx;
		}
		
		.cart .carnum .reduce.on {
			// border-color: #e3e3e3;
			color: #DEDEDE;
			font-size: 44rpx;
		}
		
		.cart .carnum .plus {
			border-left: 0;
			border-radius: 0 6rpx 6rpx 0;
			line-height: 46rpx;
		}
		
	.cart .carnum .plus.on {
			border-color: #e3e3e3;
			color: #dedede;
		}
		
	.cart .carnum .num {
			background: rgba(242, 242, 242, 1);
			color: #282828;
			font-size: 28rpx;
			border-radius: 12rpx;
			line-height: 29px;
			height: 54rpx;
		
			input {
				display: -webkit-inline-box;
			}
		}
		
</style>
